#include "CSTree.h"

void printCSTree(CSNode* t, int k)
{
	if (t)
	{
		for (int i = 0; i < k; i++)
		{
			printf(" ");
		}
		printf("%c\n", t->data);
		for (CSNode* p = t->Lchild; p != NULL; p = p->rsibling)
		{
			printCSTree(p, k + 5);
		}
	}
}

void freeTree(CSTree T)
{
	if (T)
	{
		freeTree(T->Lchild);
		freeTree(T->rsibling);
		free(T);
	}
}

void main()
{
	TElemType e[] = { 'A','B','C','D','E','F','G' };
	int degree[] = { 3,0,2,0,0,1,0 };
	int n = sizeof(e) / sizeof(e[0]);

	CSTree T;
	createCSTree_Dagree(T, e, degree, n);
	printCSTree(T, 5);
	freeTree(T);
}